

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>莫与一键发币</title>
    <meta id="i18n_pagename" content="message">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="https://static.medishares.net/css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="https://static.medishares.net/css/common.css?v=2018082901">
    <script src="https://static.medishares.net/js/jquery-3.2.1.min.js"></script>
    <script src="https://static.medishares.net/js/vue.min.js"></script>
    <script src="https://static.medishares.net/js/common.js?v=2018082901"></script>
</head>
<body>
<div class="mds-group">
    <link href="https://static.medishares.net/css/market/qixi2018.css" rel="stylesheet">
<div class="qixi">
  <div class="card">
        <div class="row">


                                      <div class="col-sm-5">
                        <div class="form-group">
                                              <label>您的EOS账户名(不要有多余空格！)</label>
                                              <input type="text" class="form-control" id="inp1" seg="1" placeholder="例： developstdio" >
                          <script>
                          function accountname(v){
                            if(v.value == ''){
                              return false;
                            }
                            //大写转小写
                            v.value = v.value.toLowerCase();
                            //判断是否为英文

                            //判断是否超过长度
                            if(v.value.length > 12){
                              return v.value = v.value.substr(0, 12);
                            }
                          }
                          </script>


                          </div>
                    <script language="javascript">
                      function checkname() //声明标识符
                      {
                      alert("检测流程:\n 1.关注“深入浅出EOS”公众号，后台回复您想发行的币的符号\n（例：MOYU）\n2.若无回复，则可以注册\n3.若回复“已被注册”，则不可再注册"); //弹出对话框
                      }
                      </script>
                                      </div>
                                      <div class="col-sm-5 col-sm-offset-1">
                                          <div class="form-group">
                                              <label>发币数量（小数点后为精确度）</label>
                                              <input type="text" class="form-control" id="inp2" seg="2" placeholder="例： 1000000000.0000" onKeyUp="number(this);" >
                          <script>
                          function number(v){
                            if(v.value == ''){
                              return false;
                            }
                            //大写转小写

                            //判断是否为英文

                            //判断是否超过长度
                            if(v.value.length > 17){
                              return v.value = v.value.substr(0, 17);
                            }
                          }
                          </script>
                                          </div>



                                      </div>
                                      <div class="col-sm-5">
                                        <div class="form-group">
                                              <label>代币符号（1-6位的大写字母）</label>
                                              <input type="text" class="form-control" id="inp3" seg="3" placeholder="例： MOYU" onKeyUp="dothis(this);">
                          <script>
                          function dothis(v){
                            if(v.value == ''){
                              return false;
                            }
                            //小写转大写
                            v.value = v.value.toUpperCase();
                            //判断是否为英文
                            if(!/^([A-Za-z]+\s?)*[A-Za-z]$/.test(v.value)){
                              return v.value = v.value.substr(0, v.value.length - 1);
                            }
                            //判断是否超过长度
                            if(v.value.length > 6){
                              return v.value = v.value.substr(0, 6);
                            }
                          }
                          </script>

                                          </div>
                                      </div>
                                  </div>
    <a href="javascript:;" class="confirm">3 EOS发币</a>
  </div>
  <div class="my-protocol right-align">
    <a href="javascript:;" id="all" >查询发币状态</a>
  </div>
  <div style="clear: both;"></div>
  <ul class="qixi-about">
    <li>
      <h3>关于莫与一键发币</h3>
      <div>只需要 30秒 3EOS，你就能发行一款属于自己的EOS发币。</div>
    </li>
    <li>
      <h3>检测代币符号是否已经被注册流程</h3>
      <ul class="application">
        <li>1.关注“深入浅出EOS”公众号，后台回复您想发行的币的符号</li>
        （例：MOYU）
        <li>2.若无回复，则可以注册</li>
        <li>3.若回复“已被注册”，则不可再注册</li>
      </ul>
    </li>
    <li>
      <h3>对于发币数量精度说明</h3>
      <ul class="application">
        <li>发币数量的精度需要按需填写！</li>
        <li>例如：</li>
        若发10个MOYU，则MOYU币总量为10，最小分割为一个币，不存在0.1这样的分割。
        <li>再例如</li>
        发10.000个MOYU，则MOYU币总量为10，最小分割为0.001个MOYU。
      </ul>
    </li>
    <li>
      <h3>注意事项</h3>
      <ul class="application">
        <li>1.莫与一键发币DApp发币只需3EOS，价格比自己发币便宜了13倍哦</li>
        <li>2.用户确认之前所填信息无误即可点击发币按钮进行发币！</li>
        <li>3.利用莫与一键发币所发币种名字唯一，不可重复</li>
        <li>4.转账成功后币即可到账，可通过eosflare.io进行查询</li>
        <li>5.关注“深入浅出EOS”公众号，后台回复“钱包显示”即可获取在钱包中显示代币的详细教程。</li>
        <li>6.由于用户填写错误造成的损失本DApp概不负责</li>
      </ul>
    </li>
    <li>
      <h3>关于作者</h3>
      <div>关于“莫与一键发币”。任何问题可以通过公众号“深入浅出EOS”联系原作者莫与。</div>
    </li>
  </ul>
</div>

<!-- loading -->
<div id="app_loading" v-bind:class="{hide:!loading}"></div>
<!-- 额外js -->
<script src='https://static.medishares.net/js/plugins/lottie_light.min.js'></script>
<script type="text/javascript">
  $(function(){
    lottie.loadAnimation({
      container: $('#app_loading')[0], // the dom element that will contain the animation
      renderer: 'svg',
      loop: true,
      autoplay: true,
      path: 'https://static.medishares.net/js/plugins/loading.json' // the path to the animation json
    });
  })
</script>

<script src="https://static.medishares.net/js/eos.min.js"></script>
<script src="https://static.medishares.net/js/md5.js"></script>
<script src="https://static.medishares.net/js/jquery.mdseos.js"></script>

<script type="text/javascript">

  var pageData = {
    // pageInit : true,
    loading : true
  }

  var vote1Vue = new Vue({
    el: '.mds-group',
    data: pageData,
  })

  $(function(){

    $.mdseos.init({"nodes":[{"jsonRpc":"https:\/\/eostestnet.medishares.net","chainID":"cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"},{"jsonRpc":"https:\/\/eosmainnet.medishares.net","chainID":"aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"}]});

    $.mdseos.app_get_account(function(){
      pageData.loading = false;
    });

    // 发起交易
    $('.confirm').on('click',function(){
      $.mdseos.app_get_account(function(){
        account = $.mdseos.getAccount();
        permission = $.mdseos.getAccountPermission();

        var mdseos = $.mdseos.getEos();

      var comment = '1-'+ $('#inp1').val() + '-' + $('#inp2').val() + '-' + $('#inp3').val();
        if( computeByteSize(comment) > 256 ){
          alert('最多只能写256个字节哦~');
          return false;
        }


        //发起购买交易
        var transaction = mdseos.transaction({
          actions:[
            {
              account: 'eosio.token',
              name: 'transfer',
              authorization: [{
                actor: account,
                permission: permission
              }],
              data: {
                from: account,
                to: 'emmmmmmmmmmm',
                quantity: '3.0000 EOS',
                memo: comment
              }
            }
          ]
        },function(error, result){
          if(error){
            alert( JSON.parse(error).error.details[0].message );
          }else{
            alert('发币成功！关注“深入浅出EOS”公众号，后台回复“钱包显示”。获取在钱包显示代币教程！');
            window.location.reload();
          }
        });
       });
    });

     $('#all').on('click',function(){
      var account = $.mdseos.getAccount();
      window.location.href=('https://eosflare.io/account/'+account);
    })


    // 计算指定字符串的字节数
    function computeByteSize(str){
      for (var i=0,byte=0; i < str.length; i++) {
        var charCode = str.charCodeAt(i);
        if (0 <= charCode && charCode <= 0x7f) {
          byte += 1;
        } else if (128 <= charCode && charCode <= 0x7ff) {
          byte += 2;
        } else if (2048 <= charCode && charCode <= 0xffff) {
          byte += 3;
        } else if (65536 < charCode && charCode <= 0x1FFFFF) {
          byte += 4;
        } else if (0x200000 < charCode && charCode <= 0x3FFFFFF) {
          byte += 5;
        } else if (0x4000000 < charCode && charCode <= 0x7FFFFFFF) {
          byte += 6;
        }
      }
      return byte
    }

  })
</script>

</div>
</body>
</html>
